package 笔试.同城58;

/**
 * @author:谢君臣
 * @Date:2021/9/11-20:37
 * @version:1.0
 * @function:
 */
public class Main02 {
    public static void main(String[] args) {

    }
    public int[] subArraySum (int[] Array, int arrayLen, int subArrayLen) {
        // write code here
        int sum = 0,max=0,index = 0;
        int [] res = new int[2];
        for (int i = 0; i < Array.length; i++) {
            if (i>=subArrayLen){
                if (sum>max){
                    max = sum;
                    index = i-subArrayLen;
                }
                sum = sum+Array[i]-Array[i-subArrayLen];
            }
            else {
                sum += Array[i];
            }
        }
        res[0] = index;
        res[1] = max;
        return res;
    }
}
